<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<!DOCTYPE html>
<head>
  <title>已取消订单</title>
  <link rel="stylesheet" href="${path}/pet/shoppingcart/css/orders.css">
  <script src="${path}/pet/home/js/jquery.min.js"></script>
  <script src="${path}/pet/user/js/bootstrap.min.js"></script>
</head>

<body>
  <div class="tab-active" id="cancel_orders"></div>
</body>

<script>
  $(function(){
    var user="<%=session.getAttribute("user")%>";
    var uid = ${user.id};
    console.log(uid);

    //根据用户ID获取已取消的订单
    var qData = {
      uid:uid,
      billState:"订单已删除",
      billType:"商品结算"
    };
    $.ajax({
      type: 'POST',
      url: '/bill/searchByUser',
      data:qData,
      dataType : "json",
      error: function () {
        console.log("失败");
      },
      success: function (result) {
        console.log("成功");
        console.log(result);
        var str = "";
        for(var key in result) {
          for (i = 0; i < result[key].length; i++) {
            console.log(result[key][i]);
            str += '<p class="tab_p">';
            str += '  <span style="float: left;font-size: 0.8rem;">'+ result[key][i].createDate +'</span>';
            str += '  <span style="float: right;font-size: 0.8rem;color: #3EAF0E">'+ result[key][i].state +'</span>';
            str += '</p>';
            str += '<div class="line"></div>';
            str += '<div class="product-item">';
            str += '  <img class="img_style" src="${path}/backstage/images/'+result[key][i].item.picUrl+'">';
            str += '</div>';
            str += '<div class="text" style="position: absolute;margin-top: 2%;">'+ result[key][i].item.itemName +'</div>';
            str += '<div class="data1">';
            str += '  <p>受保人:'+ result[key][i].insured.name +'</p>';
            str += '  <h4 style="width: 150px;float: right;display: block;">'+ result[key][i].price +'</h4>';
            str += '</div>';
            str += '<div class="aui-mail-button">';
            str += '  <a href="${path}/productDetail?id='+ result[key][i].item.id +'">再次购买</a>';
            str += '</div>';
            str += '<div class="line"></div>';
          }
        }
        $('#cancel_orders').html(str);
      }
    });
  });
</script>

<style>
  .tab_p {
    height: 25px;
    /*border: 2px solid red;*/
    padding: 0 20px;
    margin-top: 10px;
  }
  .product-item {
    margin-right: .8em;
    width: 100px;
    height: 80px;
    line-height: 70px;
    text-align: center;
    /*margin-top: 1%;*/
    display: inline-block;
    margin-top: 10px;
  }
  .line {
    background: #efefef;
    width: 100%;
    height: 2px;
  }
  .img_style {
    width: 100%;
    max-height: 100%;
    vertical-align: top;
    margin-left: 10px;
  }
  .text {
    display: inline-block;
  }
  .data1 {
    width: 200px;
    float: right;
    display: inline;
    text-align: right;
    margin-top: 10px;
    margin-right: 20px;
  }
</style>
</html>
